import { IToolTipItem } from "../../../../../com/mui/manager/IToolTipItem";
import { SWFPlayer } from "../../../scene/modle/SWFPlayer";
import { ModelType } from "../../../scene/modle/data/ModelType";
import { MountStartsEvents } from "../events/MountStartsEvents";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { CutDataUtil } from "../../../../common/tools/CutDataUtil";
import { Language } from "../../../../../extend/language/Language";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { EColor } from "../../../../../Message/Public/EColor";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
import { FilterConst } from "../../../../component/gconst/FilterConst";
type int = number;
//class MountStartsBallSp
    
    export  class MountStartsBallSp /* flash.display.Sprite */ implements IToolTipItem
    {
        constructor(arg1: int)
        {
            
            this._startsLv = arg1;
            this.initView();
            this.useHandCursor = true;
            this.buttonMode = true;
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onThisClick);
            return;
        }

        /* internal  */playEffect(): void
        {
            if (this._effectPlayer == null) 
            {
                this._effectPlayer = new SWFPlayer();
            }
            this._effectPlayer.load("MountStartsBallEffect.swf", ModelType.NormalSwf, null);
            this._effectPlayer.move(18, 22);
            this._effectPlayer.play();
            if (this.contains(this._effectPlayer) == false) 
            {
                this.addChild(this._effectPlayer);
            }
            return;
        }

        /* internal  */stopEffect(): void
        {
            if (this._effectPlayer && this.contains(this._effectPlayer)) 
            {
                this._effectPlayer.stop();
                this.removeChild(this._effectPlayer);
            }
            return;
        }

        protected onThisClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.dispatchEvent(new MountStartsEvents(MountStartsEvents.ONBALLSELECT, this._startsLv));
            return;
        }

        /* internal  */initView(): void
        {
            this._bm = ObjCreate.createBitmap("", 0, 0, this);
            LoaderHelp.addResCallBack(ResFileConst.mountStarts, this.onLoadBmResource);
            this.toolTipData = CutDataUtil.replaceNum2CHStr(this._startsLv.toString()) + Language.getString(70231);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._loaded = true;
            if (this._open) 
            {
                this.changeBm(this._tartgetColor);
            }
            else 
            {
                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsNoOpenBall);
            }
            return;
        }

        public get startsLv(): int
        {
            return this._startsLv;
        }

        /* internal  */changeBm(arg1: int): void
        {
            if (!this._open) 
            {
                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsNoOpenBall);
                return;
            }
            if (arg1 <= EColor._EColorWhite) 
            {
                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsWhiteBall);
            }
            else if (arg1 <= EColor._EColorGreen) 
            {
                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsGreenBall);
            }
            else if (arg1 <= EColor._EColorBlue) 
            {
                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsBlueBall);
            }
            else if (arg1 <= EColor._EColorPurple) 
            {
                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsPurpleBall);
            }
            else if (arg1 <= EColor._EColorOrange) 
            {
                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsOrangeBall);
            }
            else if (arg1 >= EColor._EColorRed) 
            {
                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsGoldBall);
            }
            return;
        }

        public get toolTipData()
        {
            return this._tooltipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._tooltipData = arg1;
            return;
        }

        public get open(): Boolean
        {
            return this._open;
        }

        public set open(arg1: Boolean)
        {
            this._open = arg1;
            if (this._open) 
            {
                if (this._loaded) 
                {
                    this.changeBm(this._tartgetColor);
                }
                this.playEffect();
            }
            else 
            {
                if (this._loaded) 
                {
                    this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsNoOpenBall);
                }
                this.stopEffect();
                this._bm.filters = [];
            }
            this.mouseChildren = this._open;
            this.mouseEnabled = this._open;
            return;
        }

        public get seleted(): Boolean
        {
            return this._seleted;
        }

        public set seleted(arg1: Boolean)
        {
            if (this._open) 
            {
                this._seleted = arg1;
                if (this._seleted) 
                {
                    this._bm.filters = [FilterConst.gradientGlowFilter];
                    this.dispatchEvent(new MountStartsEvents(MountStartsEvents.ONBALLSELECT, this._startsLv));
                }
                else 
                {
                    this._bm.filters = [];
                }
            }
            else 
            {
                this._seleted = false;
            }
            return;
        }

        public setTargetColor(arg1: int): void
        {
            this._tartgetColor = arg1;
            if (this._loaded) 
            {
                this.changeBm(this._tartgetColor);
            }
            return;
        }

        /* internal */ /* var */_startsLv: int;

        /* internal */ /* var */_bm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_loaded: Boolean;

        /* internal */ /* var */_open: Boolean;

        /* internal */ /* var */_seleted: Boolean;

        /* internal */ /* var */_effectPlayer: SWFPlayer;

        /* internal */ /* var */_tartgetColor: int;

        /* internal */ /* var */_tooltipData;
    }
